package com.gitee.huxing.algorithmic.daily;

/**
 * @Description: 一次编辑
 * 字符串有三种编辑操作:插入一个字符、删除一个字符或者替换一个字符。 给定两个字符串，编写一个函数判定它们是否只需要一次(或者零次)编辑。
 * @ProjectName: algorithmic-pactice
 * @Package: OneEditAway
 * @ClassName: OneEditAway
 * @Author: huxingmale
 * @DateTime: 2022-05-13 9:08
 */
public class OneEditAway {

    public static void main(String[] args) {
        String first = "a", second = "ab";
        System.out.println(oneEditAway(first, second));
    }
    public static boolean oneEditAway(String first, String second) {
        int n = first.length(), m = second.length();
        if (n > m){
            return oneEditAway(second, first);
        }
        second = second.replace(first, "");
        return second.length() <= 1;
    }
}
